<div class="summary">
	<div style='float:right;'>
		<?php
			$label = '<button class="bt2">创建新的单位团体</button>';
			$rurl= array('/admin/createArtist');
			$htmlOption = array();
			echo CHtml::link($label,$rurl,$htmlOption);
		?>
		<button class="bt2" id='reorder'>重遍排列次序</button>
	</div>
	<div style='float:left;width:200px;'>
		<h3>目前收录 </h3>
		<ul >
			<li ><?php echo count($result) ?> 个创作单位团体</li>
			<li ><?php echo $countAlbum ?> 张敬拜赞美专辑</li>
			<li ><?php echo $countSong ?> 首诗歌</li>
		</ul>
	</div>
	<div style='float:left;width:300px;'>
		<h3>语言统计</h3>
		<ul >
			<li >中文有 <?php echo $summary['cn'] ?> 个单位团体</li>
			<li >英文有 <?php echo $summary['en'] ?> 个单位团体</li>
			<li >国语有 <?php echo $summary['my'] ?> 个单位团体</li>
		</ul>
	</div>
	<div class='clear'></div>
</div>
<div class='clear' style='height:20px'></div>


<ul class='thumb-listing'>
	<?php foreach ($result as $artist): ?>
	<li aid="<?php echo $artist['id'] ?>">
		<?php ob_start(); ?>
		<div class="frame">
			<?php if (file_exists(Yii::getPathOfAlias('webroot').'/res/cover/_a'.$artist['id'].'.png')): ?>
				<img src="/res/cover/_a<?php echo $artist['id'] ?>.png" alt="Cover" title="<?php echo $artist['name'] ?>" />
			<?php else: ?>
				<img src="/res/cover/_a0.png" alt="Cover" title="<?php echo $artist['name'] ?>" />
			<?php endif ?>
			<div class="lang_select">
				<?php if ($artist['en']==1): ?>
					<div class='lang'><span class="box lang_en"></span><span class='lang-text'>EN</span></div>
				<?php endif ?>
				<?php if ($artist['cn']==1): ?>
					<div class='lang'><span class="box lang_cn"></span><span class='lang-text'>CN</span></div>
				<?php endif ?>
				<?php if ($artist['my']==1): ?>
					<div class='lang'><span class="box lang_my"></span><span class='lang-text'>MY</span></div>
				<?php endif ?>
			</div>
		</div>

		<div class="text">
			<div class='name'><?php echo $artist['name'] ?></div>
			<div class='desc'>现有 <?php echo $artist['count'] ?> 张专辑</div>
		</div>
		<?php $label = ob_get_clean(); ?>
		<?php
			$rurl= array('/listing/artist','id'=>$artist['id']);
			$htmlOption = array();
			echo CHtml::link($label,$rurl,$htmlOption);
		?>
	</li>
	<?php endforeach ?>
</ul>

<style type="text/css" media="screen">
div.lang_select {position:absolute;bottom:16px;right:0;padding:0px 4px;background-color:rgba(255,255,255,0.5);}
div.lang_select div.lang{height:12px;}
div.lang_select span.box{display:inline-block;height:8px;width:8px;border:1px solid #FFF;margin:0px;}
div.lang_select span.lang_en{background-color:#00B0BF;}
div.lang_select span.lang_cn{background-color:#BF2020;}
div.lang_select span.lang_my{background-color:#00AF50;}
div.lang_select span.lang-text{font-size:7pt;color:black;display:inline-block;margin:0;padding:0 4px;overflow:hidden;}
.thumb-listing li{position:relative;cursor:pointer;}
.thumb-listing li div.mover{display:none;}
.thumb-listing li.sortable div.mover{display:block;background-color:rgba(255,255,255,0.5);position:absolute;top:0px;bottom:0px;left:0px;right:0px;z-index:1;}
div.mover div.moveup,div.mover div.movedown{
	width:50%;height:100%;float:left;}
div.mover div.moveup:hover,div.mover div.movedown:hover{
	background-color:rgba(255,255,255,0.8);}
div.mover div.moveup{background:transparent url(img/icons/resultset_previous.png) no-repeat center center;}
div.mover div.movedown{background:transparent url(img/icons/resultset_next.png) no-repeat center center;}
</style>

<script type="text/javascript" charset="utf-8">
$(function(){
	$('.thumb-listing li').prepend('<div class="mover"><div class="moveup"></div><div class="movedown"></div></div>')
	$('div.moveup').click(function(e){
		var target = $( this );
		b = target.closest('li');
		b.prev().before(b);
	});
	$('div.movedown').click(function(e){
		var target = $( this );
		b = target.closest('li');
		b.next().after(b);
	});
	$('#reorder').click(function(e){
		var target = $(this);
		if (target.attr('sortable')=='activate') {
			target.attr('sortable','').removeClass('bt3').addClass('bt2');
			target.html('重遍排列次序');
			saveSortable();
			releaseSortable();
		} else {
			initSortable();
			target.attr('sortable','activate').removeClass('bt2').addClass('bt3');
			target.html('储存排列');
		}
	});
});
function initSortable () {

	$('.thumb-listing li').addClass('sortable');
	$('li.sortable').each(function(e){
		var target = $( this );
	});
}
function releaseSortable () {

	$('li.sortable').each(function(e){
		var target = $( this );
	});
	$('.thumb-listing li').removeClass('sortable');
}
function saveSortable () {
	var pos = {};
	var i = 1;
	$('li.sortable').each(function(){
		pos[$(this).attr('aid')]=i++;
	});
	$.post('/admin/sortArtist',pos);
}
</script>